{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "view-in-github"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/R3gm/SoniTranslate/blob/main/SoniTranslate_Colab.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "8lw0EgLex-YZ"
      },
      "source": [
        "# SoniTranslate\n",
        "\n",
        "| Description | Link |\n",
        "| ----------- | ---- |\n",
        "| 🎉 Repository | [![GitHub Repository](https://img.shields.io/badge/GitHub-Repository-black?style=flat-square&logo=github)](https://github.com/R3gm/SoniTranslate/) |\n",
        "| 🚀 Online Demo in HF | [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/r3gm/SoniTranslate_translate_audio_of_a_video_content) |\n",
        "\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "cellView": "form",
        "id": "LUgwm0rfx0_J"
      },
      "outputs": [],
      "source": [
        "# @title Install requirements for SoniTranslate\n",
        "!git clone https://github.com/r3gm/SoniTranslate.git\n",
        "%cd SoniTranslate\n",
        "\n",
        "!pip uninstall chex pandas-stubs ibis-framework albumentations albucore -y -q\n",
        "!python -m pip install -q pip==23.1.2\n",
        "!apt install git-lfs\n",
        "!git lfs install\n",
        "\n",
        "!sed -i 's|git+https://github.com/R3gm/whisperX.git@cuda_11_8|git+https://github.com/R3gm/whisperX.git@cuda_12_x|' requirements_base.txt\n",
        "!pip install -q -r requirements_base.txt\n",
        "!pip install -q -r requirements_extra.txt\n",
        "!pip install -q ort-nightly-gpu --index-url=https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ort-cuda-12-nightly/pypi/simple/\n",
        "\n",
        "Install_PIPER_TTS = True # @param {type:\"boolean\"}\n",
        "\n",
        "if Install_PIPER_TTS:\n",
        "    !pip install -q piper-tts==1.2.0\n",
        "\n",
        "Install_Coqui_XTTS = True # @param {type:\"boolean\"}\n",
        "\n",
        "if Install_Coqui_XTTS:\n",
        "    !pip install -q -r requirements_xtts.txt\n",
        "    !pip install -q TTS==0.21.1  --no-deps"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "LTaTstXPXNg2"
      },
      "source": [
        "One important step is to accept the license agreement for using Pyannote. You need to have an account on Hugging Face and `accept the license to use the models`: https://huggingface.co/pyannote/speaker-diarization and https://huggingface.co/pyannote/segmentation\n",
        "\n",
        "Get your KEY TOKEN here: https://hf.co/settings/tokens\n",
        "\n",
        "When you are creating the new Access Token in Hugging Face, make sure to tick \"Read access to contents of all public gated repos you can access\"."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "cellView": "form",
        "id": "XkhXfaFw4R4J"
      },
      "outputs": [],
      "source": [
        "#@markdown # `RUN THE WEB APP`\n",
        "YOUR_HF_TOKEN = \"\" #@param {type:'string'}\n",
        "%env YOUR_HF_TOKEN={YOUR_HF_TOKEN}\n",
        "theme = \"Taithrah/Minimal\" # @param [\"Taithrah/Minimal\", \"aliabid94/new-theme\", \"gstaff/xkcd\", \"ParityError/LimeFace\", \"abidlabs/pakistan\", \"rottenlittlecreature/Moon_Goblin\", \"ysharma/llamas\", \"gradio/dracula_revamped\"]\n",
        "interface_language = \"english\" # @param ['arabic', 'azerbaijani', 'chinese_zh_cn', 'english', 'french', 'german', 'hindi', 'indonesian', 'italian', 'japanese', 'korean', 'marathi', 'polish', 'portuguese', 'russian', 'spanish', 'swedish', 'turkish', 'ukrainian', 'vietnamese']\n",
        "verbosity_level = \"info\" # @param [\"debug\", \"info\", \"warning\", \"error\", \"critical\"]\n",
        "\n",
        "\n",
        "%cd /content/SoniTranslate\n",
        "!python app_rvc.py --theme {theme} --verbosity_level {verbosity_level} --language {interface_language} --public_url"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "KJW3KrhZJh0u"
      },
      "source": [
        "Open the `public URL` when it appears"
      ]
    }
  ],
  "metadata": {
    "accelerator": "GPU",
    "colab": {
      "gpuType": "T4",
      "include_colab_link": true,
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
